<template>
	<view>
		<uni-nav-bar left-icon="back" shadow @clickLeft="back" :border="false" title="">
			<view class="flex align-center justify-center w-100">
				
			
			你好<text class="iconfont icon-hard-drive"></text>
			</view>
			</uni-nav-bar>
			
			<view class="px-2">
				<textarea v-model="content" class="border w-100" placeholder="请说点什么" />
			</view>
			<upload-image @change="chooseImage"></upload-image>
			<view class="fixed-bottom flex align-center">
				<view class="iconfont icon-hash font-sm px-1 animate__animated" @click="upImage('aitu')" hover-class="animate__headShake" style="font-size: 25px;"></view>
				<view class="iconfont icon-mail font-sm px-1 animate__animated" @click="upImage('email')" hover-class="animate__headShake" style="font-size: 25px;"></view>
				<view class="iconfont icon-image font-sm px-1 animate__animated" @click="upImage('image')" hover-class="animate__headShake" style="font-size: 25px;"></view>
				<view class="flex align-center ml-auto py px-1 bg-danger text-white justify-center">发送</view>
			</view>
	</view>
</template>

<script>
	import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue';
	import uploadImage  from "@/components/common/upload-image.vue"
	export default {
		components:{
			uniNavBar,
			uploadImage
		},
		data() {
			return {
				listImage:[],
				content:'',
			}
		},
		onLoad() {
			
			uni.getStorage({
				key:'app-input',
				success(res) {
					let tent = this
					let list = JSON.parse(res.data);
					this.content = list.content;
					this.listImage = list.listImage;
					console.log(this.content,'list')
				}
			})
		},
		// 监听返回
		onBackPress(){
			
		},
		methods: {
			upImage(e){
				switch (e){
					// case "image":
					// this.$refs.un
					// 	break;
					// default:
					// 	break;
				}
			},
			chooseImage(e){
				console.log(e)
				this.listImage = e
			},
			back() {
				if(this.content !== ''){
					uni.showModal({
						title: 'YUDO',
						content: '还未保存，确认返回吗',
						showCancel: true,
						// cancelText: '',
						// confirmText: '',
						success: res => {
							if(res.confirm){
								this.shore()
								uni.navigateBack({
									delta: 1
								})
							}
							// return true
						},
						fail: () => {},
						complete: () => {}
					});
				}
				
				
			},
			shore(){
				let obj = {
					content:this.content,
					images:this.listImage
				}
				uni.setStorage({
					key:"app-input",
					data:JSON.stringify(obj)
				})
				console.log('111111')
			}
			
		}
	}
</script>

<style>
@import "../../common/animate.css";
@import "../../common/free.css";
@import "../../common/icon.css";
@import "../../common/uniapp.css";

</style>
